 <?php
 session_start();
 include_once ("Login/databaseconnection.php");
 $current_table="deleted_programmes";
 date_default_timezone_set("Europe/Paris");
  	$t_d=date("Y/m/d");
   $School_Id=$_GET['School_Id'];
   $Programme_Id=$_GET['Programme_Id'];
   $Year=$_GET['Year'];
   $Grade=$_GET['Grade'];
   $sqlre=mysql_query("SELECT * FROM deleted_programmes WHERE Programme_Id='$Programme_Id' AND year='$Year' AND School_Id='$School_Id' AND Grade='$Grade'");
	if(mysql_num_rows($sqlre)!=0)
	{
	$Required_Teachers=$_POST['Required_Teachers'];
		$School_Id=$_POST['School_Id'];
		$Programme_Id=$_POST['Programme_Id'];
		$Year=$_POST['Year'];
    $No_Of_Male_Students=$_POST['No_Of_Male_Students'];
	$No_Of_Female_Students=$_POST['No_Of_Female_Students'];
    $Teachers_In_Training=$_POST['Teachers_In_Training'];
	$Trained_Teachers=$_POST['Trained_Teachers'];
	$Availability_Books=$_POST['Availability_Books'];
	$Availability_Tguides=$_POST['Availability_Tguides'];
    $Last_Updated_Date=$_POST['Last_Updated_Date'];
	$Accessed_By=$_POST['Accessed_By'];
		$_SESSION['Accessed_By']=$Accessed_By;
	$sql=mysql_query("INSERT INTO programmes(Grade,School_Id,Programme_Id,Year,No_Of_Male_Students,No_Of_Female_Students,Teachers_In_Training,Trained_Teachers,Availability_Books,Availability_Tguides,Last_Updated_Date)VALUES('$Grade','$School_Id','$Programme_Id','$Year','$No_Of_Male_Students','$No_Of_Female_Students','$Teachers_In_Training','$Trained_Teachers','$Availability_Books','$Availability_Tguides','$t_d')");
if($sql)
{  $resultdel=mysql_query("DELETE FROM deleted_programmes WHERE Programme_Id='$Programme_Id' AND year='$Year' AND School_Id='$School_Id'");
  if(!$resultdel)
{
	$sql=mysql_query("INSERT INTO programmes(Grade,School_Id,Programme_Id,Year,No_Of_Male_Students,No_Of_Female_Students,Teachers_In_Training,Trained_Teachers,Availability_Books,Availability_Tguides,Last_Updated_Date)VALUES('$Grade','$School_Id','$Programme_Id','$Year','$No_Of_Male_Students','$No_Of_Female_Students','$Teachers_In_Training','$Trained_Teachers','$Availability_Books','$Availability_Tguides','$t_d')");
 $_SESSION['error']="but this record is not removed from the recycle bin!";
}
$_SESSION['error']="Successfully restored!";
}
   if(!$sql)
{
	 $_SESSION['error']="Sorry,an error occured  please try again!";
}	
}
?>
